using System;
using System.Diagnostics;

using org.fourzoas.noise.module;

namespace org.fourzoas.noise.module {
  /// <summary>
  /// Noise module that outputs the sum of the two output values from two source modules.
  /// </summary>
  /// <remarks>
  /// <img src="file://C:/temp/noise/noise/doc/html/moduleadd.png"/>
  /// <para>This noise module requires two source modules.</para>
  /// </remarks>
  public class Add : CombinerModule {
    /// <summary>
    /// Default constructor.
    /// </summary>
    public Add() : base(2) { }
    /// <summary>
    /// Gets the value of this noise module at a specific coordinate.
    /// </summary>
    /// <param name="x">The <em>x</em> coordinate.</param>
    /// <param name="y">The <em>y</em> coordinate.</param>
    /// <param name="z">The <em>z</em> coordinate.</param>
    /// <returns></returns>
    public override double GetValue(double x, double y, double z) {
      Debug.Assert(m_sourceModule[0] != null);
      Debug.Assert(m_sourceModule[1] != null);
      return m_sourceModule[0].GetValue(x, y, z) + m_sourceModule[1].GetValue(x, y, z);
    }
    /// <summary>
    /// The number of source modules needed.
    /// </summary>
    /// <returns>2</returns>
    public override int GetSourceModuleCount() {
      return 2;
    }
  }
}
